
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Pig;
import cn.edu.scau.cmi.hombio.domain.PigType;
import cn.edu.scau.cmi.hombio.domain.SaleTaskQuality;
import cn.edu.scau.cmi.hombio.domain.TaskPigsty;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class PigTypeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected PigTypeService service;

	/**
	 * Instantiates a new PigTypeServiceTest.
	 *
	 */
	public PigTypeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Return all PigType entity
	* 
	 */
	@Test
	public void findAllPigTypes() {
		// TODO: JUnit - Populate test inputs for operation: findAllPigTypes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<PigType> response = null;
		response = service.findAllPigTypes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllPigTypes
	}

	/**
	 * Operation Unit Test
	* Save an existing SaleTaskQuality entity
	* 
	 */
	@Test
	public void savePigTypeSaleTaskQualities() {
		// TODO: JUnit - Populate test inputs for operation: savePigTypeSaleTaskQualities 
		Integer id = 0;
		SaleTaskQuality related_saletaskqualities = new cn.edu.scau.cmi.hombio.domain.SaleTaskQuality();
		PigType response = null;
		response = service.savePigTypeSaleTaskQualities(id, related_saletaskqualities);
		// TODO: JUnit - Add assertions to test outputs of operation: savePigTypeSaleTaskQualities
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskPigsty entity
	* 
	 */
	@Test
	public void deletePigTypeTaskPigsties() {
		// TODO: JUnit - Populate test inputs for operation: deletePigTypeTaskPigsties 
		Integer pigtype_id = 0;
		Integer related_taskpigsties_id = 0;
		PigType response = null;
		response = service.deletePigTypeTaskPigsties(pigtype_id, related_taskpigsties_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePigTypeTaskPigsties
	}

	/**
	 * Operation Unit Test
	* Save an existing PigType entity
	* 
	 */
	@Test
	public void savePigType() {
		// TODO: JUnit - Populate test inputs for operation: savePigType 
		PigType pigtype = new cn.edu.scau.cmi.hombio.domain.PigType();
		service.savePigType(pigtype);
	}

	/**
	 * Operation Unit Test
	* Return a count of all PigType entity
	* 
	 */
	@Test
	public void countPigTypes() {
		Integer response = null;
		response = service.countPigTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: countPigTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Pig entity
	* 
	 */
	@Test
	public void deletePigTypePigs() {
		// TODO: JUnit - Populate test inputs for operation: deletePigTypePigs 
		Integer pigtype_id_1 = 0;
		Integer related_pigs_id = 0;
		PigType response = null;
		response = service.deletePigTypePigs(pigtype_id_1, related_pigs_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePigTypePigs
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskPigsty entity
	* 
	 */
	@Test
	public void savePigTypeTaskPigsties() {
		// TODO: JUnit - Populate test inputs for operation: savePigTypeTaskPigsties 
		Integer id_1 = 0;
		TaskPigsty related_taskpigsties = new cn.edu.scau.cmi.hombio.domain.TaskPigsty();
		PigType response = null;
		response = service.savePigTypeTaskPigsties(id_1, related_taskpigsties);
		// TODO: JUnit - Add assertions to test outputs of operation: savePigTypeTaskPigsties
	}

	/**
	 * Operation Unit Test
	* Delete an existing SaleTaskQuality entity
	* 
	 */
	@Test
	public void deletePigTypeSaleTaskQualities() {
		// TODO: JUnit - Populate test inputs for operation: deletePigTypeSaleTaskQualities 
		Integer pigtype_id_2 = 0;
		Integer related_saletaskqualities_id = 0;
		PigType response = null;
		response = service.deletePigTypeSaleTaskQualities(pigtype_id_2, related_saletaskqualities_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePigTypeSaleTaskQualities
	}

	/**
	 * Operation Unit Test
	* Save an existing Pig entity
	* 
	 */
	@Test
	public void savePigTypePigs() {
		// TODO: JUnit - Populate test inputs for operation: savePigTypePigs 
		Integer id_2 = 0;
		Pig related_pigs = new cn.edu.scau.cmi.hombio.domain.Pig();
		PigType response = null;
		response = service.savePigTypePigs(id_2, related_pigs);
		// TODO: JUnit - Add assertions to test outputs of operation: savePigTypePigs
	}

	/**
	 * Operation Unit Test
	* Load an existing PigType entity
	* 
	 */
	@Test
	public void loadPigTypes() {
		Set<PigType> response = null;
		response = service.loadPigTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadPigTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing PigType entity
	* 
	 */
	@Test
	public void deletePigType() {
		// TODO: JUnit - Populate test inputs for operation: deletePigType 
		PigType pigtype_1 = new cn.edu.scau.cmi.hombio.domain.PigType();
		service.deletePigType(pigtype_1);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findPigTypeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findPigTypeByPrimaryKey 
		Integer id_3 = 0;
		PigType response = null;
		response = service.findPigTypeByPrimaryKey(id_3);
		// TODO: JUnit - Add assertions to test outputs of operation: findPigTypeByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
